package com.taotao.portal.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.po.TbItem;
import com.taotao.portal.service.ItemService;

@Controller
@RequestMapping("/item")
public class ItemController {
	
	@Autowired
	ItemService itemService ;
	
	@RequestMapping("/{itemId}")
	public String getItemId(@PathVariable Long itemId,Model model){
		TbItem result = itemService.getItemById(itemId);
		model.addAttribute("item", result);
		return "item";
		
	}
	
	@RequestMapping(value="/desc/{itemId}",produces=MediaType.TEXT_HTML_VALUE+";charset=utf-8")
	@ResponseBody
	public String getItemDesc(@PathVariable Long itemId){
		 String result = itemService.getItemDesc(itemId);
		return result;
	}
	
	@RequestMapping(value="/param/{itemId}",produces=MediaType.TEXT_HTML_VALUE+";charset=utf-8")
	@ResponseBody
	public String getItemParam(@PathVariable Long itemId){
		 String result = itemService.getItemParamById(itemId);
		return result;
	}
}
